<template>
  <a-modal
    :width="1200"
    :visible="visible"
    @ok="ok()"
    @cancel="cancel()"
    footer=""
  >
    <template #footer>
    </template>
    <div ref="word"></div>
  </a-modal>
</template>

<script>
import EpaWeekly from '@/myService/EpaWeekly'

const docx = require("docx-preview");
window.JSZip = require("jszip");
export default {
  name: 'Preview',
  data(){
    return{
      visible:false,
      id:null,
    }
  },
  methods:{
    open(record) {
      console.log(record)
      this.id=record.id;
      console.log(this.id)
      this.visible = true
      this.loading()
    },
    ok(){
      this.visible=false
    },
    cancel(){
      this.visible=false
    },
    loading(){
      EpaWeekly.previewWord({id:this.id}).then((res)=>{
        const blob = new Blob([res.data], {
          type: 'application/msword; charset=utf-8'
        })
        docx.renderAsync(blob, this.$refs.word);
      })
    }
  }
}
</script>

<style scoped>

</style>